<?php 
	require_once("models/config.php");
	require_once("ui.php");
	require_once("stats/db.php");
	
	require_once("pie.php");
	require_once("graphs/graph-settings.php");
?>

<?php if(!isUserLoggedIn()) {
	header ("location: login.php");
	die();
}

	global $loggedInUser;
?>
		
<?php printPageHead(null, null); ?>

	<?php printNavigationBar('index', NAVIGATION_ITEM_ALL_STATS) ?>		
		
		<div id="content" class="container_16 clearfix">
			<div class="grid_16">
				<?php
					$developmentTime = getAllDevelopmentTime(STANDART_USER_GROUP_ID);
					$debuggingTime = getAllDebuggingTime(STANDART_USER_GROUP_ID);
					$reportsCount = getRecordsCount(STANDART_USER_GROUP_ID);
					
					$userList = new UserStatsList();
					$userList->loadStats();
					
					$usersCount = count($userList->users);
					
					$averageDevelTime = ($usersCount == 0) ? 0 : $developmentTime / $usersCount;  
					$averageDebugTime = ($usersCount == 0) ? 0 : $debuggingTime / $usersCount;  
					
					printOverallStats($reportsCount, $averageDevelTime, $averageDebugTime,
						$loggedInUser->user_id);
				 ?>
			</div>
			
			<img src="graphs/overall.debugging.time.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
			<img src="graphs/unknown.cause.debugging.time.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
			<img src="graphs/debugging.attempts.count.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
			<img src="graphs/feelings.participant.graph.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
			<img src="graphs/complexity-time.dependence.graph.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
			<img src="pie.overall.detection.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
			<img src="pie.overall.root.causes.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>
			<img src="pie.overall.root.causes.time.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
			<img src="memory.corruption.influence.graph.php" width="<?php echo GRAPH_WIDTH; ?>" height="<?php echo GRAPH_HEIGHT; ?>"></img>			
		</div>

<?php printPageFoot(); ?>
